<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018-07-19
 * Time: 下午 4:21
 */
namespace app\admin\model;
use think\Model;
class CarModel extends Model{
    // 确定链接表名
    protected $name = 'car';
    //查询车列表
    public function getCarByWhere($where, $offset, $limit,$join,$condition)
    {
        return $this->join($join,$condition)->where($where)->limit($offset, $limit)->order('snake_car.car_id desc')->select();
    }
    //查询会员名下有几辆车 $mid 会员ID
    public function getCarNum($mid){
        $map['member_id'] = $mid;
        return $this->where($map)->count();
    }
    //查询单个车信息 $cid 车ID
    public function getOneCarInfo($cid){
        $map['car_id'] = $cid;
        return $this->where($map)->find();
    }
    //查询车列表 $mid 会员iD
    public function getMemberCarList($mid){
        $map['member_id'] = $mid;
        return $this->where($map)->select();
    }
    //获取车辆总条数
    public function getCarCount($where,$join,$condition){
        return $this->join($join,$condition)->where($where)->count();
    }
    //修改车辆信息
    public function getCarUpdate($map,$data){
        return $this->where($map)->update($data);
    }
    //返回是否投保
    public function getCarInsure($str){
        if($str == 1){
            return '可投保';
        }else{
            return '不可投保';
        }
    }
    //查询全部不分页
    public function getCarByWhereData($where,$join,$condition)
    {
        return $this->join($join,$condition)->where($where)->order('snake_car.car_id desc')->select();
    }
}